package com.shanyin.framework.member.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import reactor.core.publisher.Mono;

/***
 ** @category <p>使用{@link RefreshScope}注解的类，会在接到SpringCloud配置中心配置刷新的时候，自动将新的配置更新到该类对应的字段中。</p>
 ** @author qing.yunhui
 ** @email: 280672161@qq.com
 ** @createTime: 2018年6月6日上午11:01:47
 **/
@RestController
@RefreshScope
public class HelloController {
	
	Logger logger=LoggerFactory.getLogger(getClass());

	//下面代码、需要在配置中心服务启动后、才能正常调用！
	
    @Value("${info.profile:error}")
    private String profile;
    
    @Value("${info.profile}")
    private String infoProfile;
    
    @Value("${info:profile}")
    private String infoProfile2;
    
    @GetMapping("infos")
    public String infos() {
    	logger.info("==========>infoProfile={}.infoProfile2={}.",new Object[] {infoProfile,infoProfile2});
    	return infoProfile+infoProfile2;
    }

    @GetMapping("/info")
    public Mono<String> hello() {
        return Mono.justOrEmpty(profile);
    }

}
